# -*- coding: utf-8 -*-
# -*- author: GXR -*-
import requests
from lxml import etree


def get_proxy():
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36',
        'Referer': 'http://ip.zdaye.com/dayProxy.html',
        'Cookie': 'acw_tc=781bad3115546084918726952e359b8a1188835473df819e28b2265ef5b2b5; ASPSESSIONIDACCTTARQ=GLCMGGMADBCNDAIEHMOAKIPF; __51cke__=; Hm_lvt_8fd158bb3e69c43ab5dd05882cf0b234=1554608494,1554618373; ASPSESSIONIDAABTQARR=LAILHENAAMCDALFFOPLEHKED; __tins__16949115=%7B%22sid%22%3A%201554623754948%2C%20%22vd%22%3A%202%2C%20%22expires%22%3A%201554625560697%7D; __51laig__=5; Hm_lpvt_8fd158bb3e69c43ab5dd05882cf0b234=1554623761'
    }

    response = requests.get(url='http://ip.zdaye.com/dayProxy/ip/300627.html', headers=headers)
    response.encoding = response.apparent_encoding
    html = etree.HTML(response.text)
    data = html.xpath("//div[@class='row']/div[@class='col-md-12'][2]/div[@class='cont']/text()")
    proxy = []
    for i in data:
        url = 'http://' + i.split('@')[0]
        proxy.append(url)
    print(proxy)
    return proxy
